//
//  UIButton+Extension.swift
//  CSYMicroBlockSina
//
//  Created by 姚彦兆 on 15/11/12.
//  Copyright © 2015年 姚彦兆. All rights reserved.
//

import UIKit

extension UIButton {

    convenience init(title buttonTitle : String , titleColor : UIColor? , image : String = "" , backImage : String? , fontSize : CGFloat = 14){
    
        self.init()
        
        setTitle(buttonTitle, forState: .Normal)
        
        if backImage != nil{

            setBackgroundImage(UIImage(named: backImage!), forState: .Normal)
            
            setBackgroundImage(UIImage(named: "\(backImage)_highlighted"), forState: .Highlighted)
            
        }
        
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        
        setImage(UIImage(named: image), forState: .Normal)
        
        if titleColor != nil{
            
            setTitleColor(titleColor, forState: .Normal)
            
        }
    
    }


}